/*********************************************************************\
*
*                  (c) lkc
*                  All Rights Reserved. lkc Confidential
*
\*********************************************************************/
/*********************************************************************\
*   Title                      :
*
*   Module Description         :
*
*   Author                     : lkc
*
*   Created                    : 2019-11-12
*
\*********************************************************************/

#ifndef PROTOCOLPODXINWANG_H
#define PROTOCOLPODXINWANG_H

#include "Communicate.h"


#ifdef POD_XINWANG_COMM_TYPE_IS_QT
#include <QObject>
#include "ProtocolBaseQt.h"
class ProtocolPodXinWang : public QObject, public ProtocolBaseQt
{
    Q_OBJECT
#else
#include "ProtocolBasePosix.h"
class ProtocolPodXinWang : public ProtocolBasePosix
{
#endif//#ifdef POD_COMM_TYPE_IS_QT
public:
    static ProtocolPodXinWang& GetInstance() {return m_Instance;}//获取实例
    ProtocolPodXinWang& operator = (const ProtocolPodXinWang&) = delete;
    ProtocolPodXinWang(const ProtocolPodXinWang&) = delete;
private:
    static ProtocolPodXinWang m_Instance;
    ProtocolPodXinWang() {}
public:
    int Passthrough(const unsigned char *sendBuf, int dataLen);//透传
    void ExtractData(const unsigned char* data, int nLength) override;
    unsigned char GetMode() ;
    float GetPitch() {return m_pitch;}//俯仰角
    float GetYaw() {return m_yaw;}//航向角
    int GetSelfCheck();









private:
    void EventReceiveFrameParse();
    void CycleReceiveFrameParse();
    void SelfCheckParse();
    int CycleSendOnce() override {return -1;}

private:
    const static int FRAME_LENGTH_RECEIVE_CYCLE = 10;
    const static unsigned char HEAD1_CYCLE = 0x7E;
    const static unsigned char HEAD2_CYCLE = 0x01;
    const static unsigned char END_CYCLE = 0x7F;

    const static int FRAME_LENGTH_RECEIVE_EVENT = 7;
    const static unsigned char HEAD1_EVENT = 0xFF;
    const static unsigned char HEAD2_EVENT = 0x01;

    unsigned char m_mode = 4;
    float m_pitch = 0;//俯仰角
    float m_yaw = 0;//航向角
    unsigned char m_selfCheck = 0;//自检
};


#endif // PROTOCOLPODXINWANG_H

/********************************************************************\
 *
 * REVISION RECORDS
 *
\*********************************************************************/
/*********************************************************************/
/*
 *
 *
 *
\*********************************************************************/
/*------------------------------The End------------------------------*/
